var selectNode;
var parentNode;
var rootNode;
var categorytree = new eiTreeModel('ZMCP07');
var isAddedRefresh = false;
var treeObj;

//启动事件处理
$(document).ready(function() {
	efregion.show('ef_region_inqu');
	$("#_left").resizable({
		handles: "e",
		 iframeFix: true,  
		 stop: function( event, ui ) {
			 $("#_right").css("margin-left",  $("#_left").outerWidth());
		 }
	});
});

efform_onload = function ()
{
};

function configTree(tree) {
	  tree.emptyNodeAsLeaf = false;
	  tree.activeEmptyJudger = false;
	  tree.topNodeActive = false;
	  tree.nodeInitializer = treeNodeInitializer;
	  tree.initialExpandDepth = 1;
      tree.hideRoot = true;
      treeObj = tree;
      tree._rootNode.active(true);
}

function treeNodeInitializer(node) {
    node.textClicked = function(){ 
    	selectNode = node;
    	parentNode=node.parent();
        var leaf = node.data().leaf;
        var label = node.data().label;  
        var text = node.data().text;  

    	var strs = new Array(); //定义一数组
    	strs = label.split("-"); //字符分割
    	if(strs.length ==1)
		{
    		var Year=strs[0];
    		var Page="ZMCP08";
        	var url="DispatchAction.do?efFormEname="+Page+"&fdPlanYear="+Year;
        	ef.get("_right_iframe").src=url;
		
		}else
		{
			var Year=strs[0];
			var Month=strs[1];
			if(Month < 10) {
				Month = "0"+Month;
			}
        	var Page="ZMCP09";
        	var url="DispatchAction.do?efFormEname="+Page+"&fdPlanYear="+Year+"&fdPlanMonth="+Month;
        	ef.get("_right_iframe").src=url;
		}
    };
}

function efgrid_onAjaxSubmitSuccess(gridId, service_name,method_name, eiInfo){
    var grid = efgrid.getGridObject(gridId);
    grid.refresh(eiInfo);
    if(isAddedRefresh&&selectNode){
        if(selectNode.leaf){
            if(selectNode._parent){
                selectNode._parent.reload();
            }else{
                treeObj._rootNode.reload();
            }
        }else{
            selectNode.reload();
        }
        isAddedRefresh = false;
    }
}